﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraGrid.Views.Grid;
using System.Drawing;
using ProgNetComponentsDx.Options;

namespace Wydatki
{
    public static class Extensions
    {
        public static void SetFocusedRowStyle(this GridView view)
        {
            string str = OptionCache.GetOptionValue(Init.InitFormOptionNames.Wyglad.KolorZaznaczonegoWiersza).AsString();
            if (str.IsNotNull() && str != "Color [Empty]")
                view.Appearance.FocusedRow.BackColor = str.AsColor();
            else
                view.Appearance.FocusedRow.Options.UseBackColor = false;

            str = OptionCache.GetOptionValue(Init.InitFormOptionNames.Wyglad.KolorTekstuZaznaczonegoWiersza).AsString();
            if (str.IsNotNull() && str != "Color [Empty]")
                view.Appearance.FocusedRow.ForeColor = str.AsColor();
            else
                view.Appearance.FocusedRow.Options.UseForeColor = false;
            
            if (view.GridControl != null)
                view.GridControl.Invalidate();

        }
    }
}
